PopupMenu Class

A control that presents a list of items. The user can select one item.

Events

Change

GotFocus

LostFocus

MouseDown

MouseUp


Properties

Bold

ListCount

DataField

ListIndex

DataSource

Text

InitialValue

TextFont

Italic

TextSize

List

Underline


Methods

AddRow

AddSeparator

DeleteAllRows

InsertRow

RemoveRow

RowTag


More information available in parent classes: RectControl:Control:Object

The ComboBox control is similar except that the user also has the option of typing an item instead of choosing one from the list of items.

Because this is a RectControl, see the RectControl for other properties and events that are common to all RectControl objects.


Examples

This code in the Open event handler populates a popup menu and sets the initial value to the current month:

Dim s as String
Dim i,last as Integer
Dim d as New Date
s="January,February,March,April,May,June,July," _
     +"August,September,October,November,December"
last= CountFields(s,",")
For i=1 to last
 me.addRow NthField(s,",",i)
Next
me.ListIndex=d.Month-1

Examine the value of ListIndex in the Change event handler to determine which item was selected.

This example adds an item to PopupMenu

PopupMenu1.addrow "October"

1.

This example populates the RowTag identifier with a sequence number

Dim i,nItems as Integer
nItems= Me.ListCount-1
For i=0 to nitems
  Me.rowTag(i)=i
Next

:

Since RowTag is a Variant, you must first convert it to an Integer if you want to compare it to another integer. Do this with a simple assignment statement such as:

Dim RecID as Integer
RecID=PopupMenu1.Rowtag(1)

Then compare RecID to another Integer.

This example opens a new window when an item is chosen.

Sub Change()
Dim w As ListEditorWindow
 If PopupMenu1.text="Edit List..." Then
 w= New ListEditorWindow
 End If

Changing the selected item in a Popup

PopupMenu1.listIndex=3

Menu:

Displaying the RowTag of the selected menu item:

EditField1.text=popupmenu1.rowtag(popupMenu1.listindex)

See Also

BevelButton, ContextualMenu, ComboBox, EditField controls; RectControl class.